﻿using UnityEngine;
using System.Collections;

// A wall between two cells.
public class MazeWall : MazeCellEdge {

	// Run on start up.
	void Start() {
		Quaternion rot = transform.parent.localRotation;
		Transform child = transform.GetChild(0);
		child.localRotation = rot;
		Vector3 pos = child.localPosition;
		BoxCollider2D box = (BoxCollider2D)collider2D;
		Vector2 boxPos = box.center;
		if(direction.Equals (MazeDirection.North) || direction.Equals (MazeDirection.West)) {
			pos.y += .5f;
			boxPos.y += .5f;
		}
		else if(direction.Equals(MazeDirection.South) || direction.Equals(MazeDirection.East)) {
			pos.y -= .5f;
			boxPos.y -= .5f;
		}
		box.center = boxPos;
		child.localPosition = pos;
	}

	// This is a wall.
	public override bool isWall() {
		return true;
	}
}
